﻿@using Smartstore.Web.Models.Catalog

@model ProductDetailsModel

@{
    var items = Model.BundledItems.Where(x => x.BundleItem.Visible).ToList();
}

@if (items.Count == 0)
{
    <div class="alert alert-warning">
        @T("Products.NoBundledItems")
    </div>
    return;
}

<div class="card-body">
    <h4 sm-if="items.Any() && Model.BundleTitleText.HasValue()" class="h5 pd-bundle-title">@Model.BundleTitleText</h4>

    <ul class="pd-bundle-summary list-unstyled mb-3">
        @foreach (var item in items)
        {
            var gallery = item.MediaGalleryModel;
            var img = gallery.Files?.FirstOrDefault();

            <li class="pd-bundle-summary-item">
                @if (item.BundleItem.Quantity > 1)
                {
                    if (img != null)
                    {
                        <span class="pd-bundle-summary-item-qty badge badge-pill badge-success">@(item.BundleItem.Quantity)&#215;</span>
                    }
                    else
                    {
                        <span><strong>@(item.BundleItem.Quantity)&#215;</strong></span>
                    }
                }
                @if (item.VisibleIndividually)
                {
                    if (img != null)
                    {
                        <a asp-route="Product" asp-route-SeName="@item.SeName" title="@T("Products.Details")">
                            <img sm-file="img" sm-size="gallery.ThumbSize" />
                        </a>
                    }
                    else
                    {
                        <a asp-route="Product" asp-route-SeName="@item.SeName" title="@T("Products.Details")">@item.Name</a>
                    }
                }
                else
                {
                    if (img != null)
                    {
                        <img sm-file="img" sm-size="gallery.ThumbSize" />
                    }
                    else
                    {
                        <span>@item.Name</span>
                    }
                }
            </li>
        }
    </ul>

    <div class="pd-bundle-price-container" data-partial="BundlePrice">
        <partial name="Product.Bundle.Price" model="Model" />
    </div>
</div>

<partial name="Product.Bundle.Items" model="items" />